﻿<table cellpadding="0" cellspacing="1" border="0" width="98%" style="margin-top:6px;" class="formtable" id="maintable">
    <tr>
        <th style="width:100px;">编辑模式：</th>
        <td>
            <select class="myselect" id="editmode" style="width:227px" onchange="editmode_change(this.value);">
                <option value=""></option>
                <option value="text">文本框</option>
                <option value="textarea">文本域</option>
                <option value="select">下拉选择</option>
                <option value="checkbox">复选框</option>
                <option value="radio">单选框</option>
                <option value="datetime">日期时间</option>
                <option value="org">组织架构选择</option>
                <option value="dict">数据字典选择</option>
                <option value="files">附件</option>
            </select>
        </td>
    </tr>
    <tr id="mode_text" style="display:none;">
        <td colspan="2">
            <div id="tabdiv_text" style="width:100%;">
                <div id="tabdiv_text_base" style="padding-bottom:8px; padding-top:8px;" title="&nbsp;&nbsp;属性&nbsp;&nbsp;">
                    <table cellpadding="0" cellspacing="1" border="0" width="100%" class="formtable">
                        <tr>
                            <th style="width:100px;">默认值：</th>
                            <td>
                                <select class="myselect" id="text_defaultvalueselect" name="defaultvalueselect" onchange="parent.insertElementText(document.getElementById('text_defaultvalue'), this.value);" style="width:190px"></select>
                                <input type="text" class="mytext" id="text_defaultvalue" style="width:380px; margin-right:6px;" />
                            </td>
                        </tr>
                        <tr>
                            <th>值类型：</th>
                            <td><select class="myselect" id="text_valuetype" name="valuetype"></select></td>
                        </tr>
                        <tr>
                            <th>最大字符数：</th>
                            <td><input type="text" id="text_maxlength" class="mytext" style="width:150px" /></td>
                        </tr>
                        <tr>
                            <th>宽度：</th>
                            <td><input type="text" id="text_width" class="mytext" style="width:150px" /></td>
                        </tr>
                    </table>
                </div>
                <div id="tabdiv_text_event" style="overflow:auto; padding-top:8px;" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
                    @(await Html.PartialAsync("Events_SubTable.cshtml", "text"))
                </div>
            </div>
            <script type="text/javascript">
                    new RoadUI.Tab({ id: "tabdiv_text", replace: true, contextmenu: false });
            </script>
        </td>
    </tr>

    <tr id="mode_textarea" style="display:none;">
        <td colspan="2">
            <div id="tabdiv_textarea" style="width:100%;">
                <div id="tabdiv_textarea_base" style="padding-bottom:8px; padding-top:8px;" title="&nbsp;&nbsp;属性&nbsp;&nbsp;">
                    <table cellpadding="0" cellspacing="1" border="0" width="100%" class="formtable">
                        <tr>
                            <th style="width:100px;">默认值：</th>
                            <td>
                                <select class="myselect" id="textarea_defaultvalueselect" name="defaultvalueselect" onchange="parent.insertElementText(document.getElementById('textarea_defaultvalue'), this.value);" style="width:190px"></select>
                                <input type="text" class="mytext" id="textarea_defaultvalue" style="width:380px; margin-right:6px;" />
                            </td>
                        </tr>
                        <tr>
                            <th>值类型：</th>
                            <td><select class="myselect" id="textarea_valuetype" name="valuetype"></select></td>
                        </tr>
                        <tr>
                            <th>最大字符数：</th>
                            <td><input type="text" id="textarea_maxlength" class="mytext" style="width:150px" /></td>
                        </tr>
                        <tr>
                            <th>宽度：</th>
                            <td><input type="text" id="textarea_width" class="mytext" style="width:150px" /></td>
                        </tr>
                        <tr>
                            <th>高度：</th>
                            <td><input type="text" id="textarea_height" class="mytext" style="width:150px" /></td>
                        </tr>
                    </table>
                </div>
                <div id="tabdiv_textarea_event" style="overflow:auto; padding-top:8px;" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
                    @(await Html.PartialAsync("Events_SubTable.cshtml", "textarea"))
                </div>
            </div>
            <script type="text/javascript">
                    new RoadUI.Tab({ id: "tabdiv_textarea", replace: true, contextmenu: false });
            </script>
        </td>
    </tr>

    <tr id="mode_select" style="display:none;">
        <td colspan="2" style="padding:0; margin:0;">
            <div id="tabdiv_select" style="width:100%;">
                <div id="tabdiv_select_base" style="padding-bottom:8px; padding-top:8px;" title="&nbsp;&nbsp;属性&nbsp;&nbsp;">
                    <table cellpadding="0" cellspacing="1" border="0" width="98%" class="formtable" style="margin:0 auto;">
                        <tr>
                            <th style="width:100px;">默认值：</th>
                            <td>
                                <select class="myselect" id="select_defaultvalueselect" name="defaultvalueselect" onchange="parent.insertElementText(document.getElementById('select_defaultvalue'), this.value);" style="width:190px"></select>
                                <input type="text" class="mytext" id="select_defaultvalue" style="width:380px; margin-right:6px;" />
                            </td>
                        </tr>
                        <tr>
                            <th style="width:110px;">宽度：</th>
                            <td>
                                <input type="text" id="select_width" class="mytext" style="width:150px" />
                                <input type="checkbox" name="select_hasempty" id="select_hasempty" value="1" style="vertical-align:middle; margin-left:15px;" />
                                <label style="vertical-align:middle;" for="select_hasempty">是否添加空选项</label>
                            </td>
                        </tr>
                        <tr>
                            <th><input type="radio" value="select_dsdict" name="select_ds" style="vertical-align:middle;" id="select_ds1" /><label style="vertical-align:middle;" for="select_ds1">数据源(字典):</label></th>
                            <td>
                                <input type="text" class="mydict" id="select_ds_dict" more="0" value="" style="width:200px;" />
                                &nbsp;&nbsp;<input type="checkbox" id="select_ds_dict_ischild" value="1" style="vertical-align:middle;" /><label for="select_ds_dict_ischild" style="vertical-align:middle;">是否加载下级</label>
                                &nbsp;&nbsp;值字段：<select class="myselect" id="select_ds_dict_valuefield">
                                    <option value="id">Id</option>
                                    <option value="code">唯一代码</option>
                                    <option value="value">值</option>
                                    <option value="title">标题</option>
                                    <option value="note">备注</option>
                                    <option value="other">其他</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th><input type="radio" value="select_dssql" name="select_ds" style="vertical-align:middle;" id="select_ds2" /><label style="vertical-align:middle;" for="select_ds2">数据源(SQL):</label></th>
                            <td>
                                <div><textarea cols="1" rows="1" class="mytextarea" id="select_ds_sql" style="width:99%; height:65px;"></textarea></div>
                                <div style="margin:3px 0;">格式：SELECT 值字段,标题字段 FROM 表名 WHERE 条件</div>
                            </td>
                        </tr>
                        <tr>
                            <th><input type="radio" value="select_dsstring" name="select_ds" style="vertical-align:middle;" id="select_ds3" /><label style="vertical-align:middle;" for="select_ds3">数据源(表达式):</label></th>
                            <td>
                                <div><textarea cols="1" rows="1" class="mytextarea" id="select_ds_string" style="width:99%; height:65px;"></textarea></div>
                                <div>
                                    <div style="margin:3px 0; float:left; ">格式：选项文本1,选项值1;选项文本2,选项值2</div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>联动：</th>
                            <td>
                                字段：<select id="select_Linkage_Field" class="myselect" style="width:180px;"></select>
                                <span style="margin-left:8px;">
                                    <label style="vertical-align:middle;">选项来源：</label><input style="vertical-align:middle;" type="radio" onclick="$('#select_Linkage_Source_sql_link').show();" value="sql" id="select_Linkage_Source_sql" name="select_Linkage_Source" /><label style="vertical-align:middle;" for="select_Linkage_Source_sql">SQL</label>
                                    <input style="vertical-align:middle;" type="radio" value="url" id="select_Linkage_Source_url" onclick="$('#select_Linkage_Source_sql_link').hide();" name="select_Linkage_Source" /><label style="vertical-align:middle;" for="select_Linkage_Source_url">URL</label>
                                    <input style="vertical-align:middle;" type="radio" value="dict" id="select_Linkage_Source_dict" onclick="$('#select_Linkage_Source_sql_link').hide();" name="select_Linkage_Source" /><label style="vertical-align:middle;" for="select_Linkage_Source_dict">数据字典下级</label>
                                </span>
                                <div style="margin-top:6px; display:none;" id="select_Linkage_Source_sql_link">
                                    数据连接：<select class="myselect" id="select_Linkage_Source_sql_conn"><option value=""></option>@Html.Raw(ViewData["connOptions"])</select>
                                    <input type="button" value="测试SQL" onclick="testSql($('#select_Linkage_Source_text').val(), $('#select_Linkage_Source_sql_conn').val());" class="mybutton" />
                                </div>
                                <div style="margin-top:6px;">
                                    <textarea class="mytextarea" id="select_Linkage_Source_text" style="height:60px; width:99%;"></textarea>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="tabdiv_select_event" style="overflow:auto; padding-top:8px;" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
                    @(await Html.PartialAsync("Events_SubTable.cshtml", "select"))
                </div>
            </div>
            <script type="text/javascript">
                    new RoadUI.Tab({ id: "tabdiv_select", replace: true, contextmenu: false });
            </script>
        </td>
    </tr>

    <tr id="mode_checkbox" style="display:none;">
        <td colspan="2" style="padding:0; margin:0;">
            <div id="tabdiv_checkbox" style="width:100%;">
                <div id="tabdiv_checkbox_base" style="padding-bottom:8px; padding-top:8px;" title="&nbsp;&nbsp;属性&nbsp;&nbsp;">
                    <table cellpadding="0" cellspacing="1" border="0" width="98%" class="formtable" style="margin:0 auto;">
                        <tr>
                            <th style="width:100px;">默认值：</th>
                            <td>
                                <select class="myselect" id="checkbox_defaultvalueselect" name="defaultvalueselect" onchange="parent.insertElementText(document.getElementById('checkbox_defaultvalue'), this.value);" style="width:190px"></select>
                                <input type="text" class="mytext" id="checkbox_defaultvalue" style="width:380px; margin-right:6px;" />
                            </td>
                        </tr>
                        <tr>
                            <th style="width:110px;"><input type="radio" value="checkbox_dsdict" name="checkbox_ds" style="vertical-align:middle;" id="checkbox_ds1" /><label style="vertical-align:middle;" for="checkbox_ds1">数据源(字典):</label></th>
                            <td>
                                <input type="text" class="mydict" id="checkbox_ds_dict" more="0" value="" style="width:200px;" />
                                &nbsp;&nbsp;值字段：<select class="myselect" id="checkbox_ds_dict_valuefield">
                                    <option value="id">Id</option>
                                    <option value="code">唯一代码</option>
                                    <option value="value">值</option>
                                    <option value="title">标题</option>
                                    <option value="note">备注</option>
                                    <option value="other">其他</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th><input type="radio" value="checkbox_dssql" name="checkbox_ds" style="vertical-align:middle;" id="checkbox_ds2" /><label style="vertical-align:middle;" for="checkbox_ds2">数据源(SQL):</label></th>
                            <td>
                                <div><textarea cols="1" rows="1" class="mytextarea" id="checkbox_ds_sql" style="width:99%; height:70px;"></textarea></div>
                                <div style="margin:3px 0;">格式：SELECT 值字段,标题字段 FROM 表名 WHERE 条件</div>
                            </td>
                        </tr>
                        <tr>
                            <th><input type="radio" value="checkbox_dsstring" name="checkbox_ds" style="vertical-align:middle;" id="checkbox_ds3" /><label style="vertical-align:middle;" for="checkbox_ds3">数据源(表达式):</label></th>
                            <td>
                                <div><textarea cols="1" rows="1" class="mytextarea" id="checkbox_ds_string" style="width:99%; height:70px;"></textarea></div>
                                <div>
                                    <div style="margin:3px 0;">格式：选项文本1,选项值1;选项文本2,选项值2</div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="tabdiv_checkbox_event" style="overflow:auto; padding-top:8px;" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
                    @(await Html.PartialAsync("Events_SubTable.cshtml", "checkbox"))
                </div>
            </div>
            <script type="text/javascript">
                    new RoadUI.Tab({ id: "tabdiv_checkbox", replace: true, contextmenu: false });
            </script>
        </td>
    </tr>

    <tr id="mode_radio" style="display:none;">
        <td colspan="2" style="padding:0; margin:0;">
            <div id="tabdiv_radio" style="width:100%;">
                <div id="tabdiv_radio_base" style="padding-bottom:8px; padding-top:8px;" title="&nbsp;&nbsp;属性&nbsp;&nbsp;">
                    <table cellpadding="0" cellspacing="1" border="0" width="98%" class="formtable" style="margin:0 auto;">
                        <tr>
                            <th style="width:100px;">默认值：</th>
                            <td>
                                <select class="myselect" id="radio_defaultvalueselect" name="defaultvalueselect" onchange="parent.insertElementText(document.getElementById('radio_defaultvalue'), this.value);" style="width:190px"></select>
                                <input type="text" class="mytext" id="radio_defaultvalue" style="width:380px; margin-right:6px;" />
                            </td>
                        </tr>
                        <tr>
                            <th style="width:110px;"><input type="radio" value="radio_dsdict" name="radio_ds" style="vertical-align:middle;" id="radio_ds1" /><label style="vertical-align:middle;" for="radio_ds1">数据源(字典):</label></th>
                            <td>
                                <input type="text" class="mydict" id="radio_ds_dict" more="0" value="" style="width:200px;" />
                                &nbsp;&nbsp;值字段：<select class="myselect" id="radio_ds_dict_valuefield">
                                    <option value="id">Id</option>
                                    <option value="code">唯一代码</option>
                                    <option value="value">值</option>
                                    <option value="title">标题</option>
                                    <option value="note">备注</option>
                                    <option value="other">其他</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th><input type="radio" value="radio_dssql" name="radio_ds" style="vertical-align:middle;" id="radio_ds2" /><label style="vertical-align:middle;" for="radio_ds2">数据源(SQL):</label></th>
                            <td>
                                <div><textarea cols="1" rows="1" class="mytextarea" id="radio_ds_sql" style="width:99%; height:70px;"></textarea></div>
                                <div style="margin:3px 0;">格式：SELECT 值字段,标题字段 FROM 表名 WHERE 条件</div>
                            </td>
                        </tr>
                        <tr>
                            <th><input type="radio" value="radio_dsstring" name="radio_ds" style="vertical-align:middle;" id="radio_ds3" /><label style="vertical-align:middle;" for="radio_ds3">数据源(表达式):</label></th>
                            <td>
                                <div><textarea cols="1" rows="1" class="mytextarea" id="radio_ds_string" style="width:99%; height:70px;"></textarea></div>
                                <div>
                                    <div style="margin:3px 0;">格式：选项文本1,选项值1;选项文本2,选项值2</div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="tabdiv_radio_vents" style="overflow:auto; padding-top:8px;" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
                    @(await Html.PartialAsync("Events_SubTable.cshtml", "radio"))
                </div>
            </div>
            <script type="text/javascript">
                    new RoadUI.Tab({ id: "tabdiv_radio", replace: true, contextmenu: false });
            </script>
        </td>
    </tr>

    <tr id="mode_datetime" style="display:none;">
        <td colspan="2" style="padding:0; margin:0;">
            <div id="tabdiv_datetime" style="width:100%;">
                <div id="tabdiv_datetime_base" style="padding-bottom:8px; padding-top:8px;" title="&nbsp;&nbsp;属性&nbsp;&nbsp;">
                    <table cellpadding="0" cellspacing="1" border="0" width="100%" class="formtable">
                        <tr>
                            <th style="width:100px;">默认值：</th>
                            <td>
                                <select class="myselect" id="datetime_defaultvalueselect" name="defaultvalueselect" onchange="parent.insertElementText(document.getElementById('datetime_defaultvalue'), this.value);" style="width:190px"></select>
                                <input type="text" class="mytext" id="datetime_defaultvalue" style="width:380px; margin-right:6px;" />
                            </td>
                        </tr>

                        <tr>
                            <th>宽度：</th>
                            <td><input type="text" id="datetime_width" class="mytext" style="width:150px" /></td>
                        </tr>
                        <tr>
                            <th>选择范围：</th>
                            <td>
                                <input type="text" id="datetime_min" class="mycalendar" style="width:100px;" />
                                &nbsp;至&nbsp;<input type="text" id="datetime_max" class="mycalendar" style="width:100px;" />
                            </td>
                        </tr>
                        <tr>
                            <th>是否选时间：</th>
                            <td><input type="checkbox" id="datetime_istime" value="1" style="vertical-align:middle;" /><label for="datetime_istime" style="vertical-align:middle;">是否允许选择时间</label></td>
                        </tr>
                        <tr>
                            <th>格式：</th>
                            <td><input type="text" id="datetime_format" class="mytext" style="width:180px" /></td>
                        </tr>
                    </table>
                </div>
                <div id="tabdiv_datetime_events" style="overflow:auto; padding-top:8px;" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
                    @(await Html.PartialAsync("Events_SubTable.cshtml", "datetime"))
                </div>
            </div>
            <script type="text/javascript">
                    new RoadUI.Tab({ id: "tabdiv_datetime", replace: true, contextmenu: false });
            </script>
        </td>
    </tr>

    <tr id="mode_org" style="display:none;">
        <td colspan="2" style="padding:0; margin:0;">
            <div id="tabdiv_org" style="width:100%;">
                <div id="tabdiv_org_base" style="padding-bottom:8px; padding-top:8px;" title="&nbsp;&nbsp;属性&nbsp;&nbsp;">
                    <table cellpadding="0" cellspacing="1" border="0" width="100%" class="formtable">
                        <tr>
                            <th style="width:100px;">默认值：</th>
                            <td>
                                <select class="myselect" id="org_defaultvalueselect" name="defaultvalueselect" onchange="parent.insertElementText(document.getElementById('org_defaultvalue'), this.value);" style="width:190px"></select>
                                <input type="text" class="mytext" id="org_defaultvalue" style="width:380px; margin-right:6px;" />
                            </td>
                        </tr>
                        <tr>
                            <th>宽度：</th>
                            <td><input type="text" id="org_width" class="mytext" style="width:150px" /></td>
                        </tr>
                        <tr>
                            <th>选择范围：</th>
                            <td>
                                <div>
                                    <input type="radio" value="0" name="org_rang" id="org_rang_0" style="vertical-align: middle;" /><label for="org_rang_0" style="vertical-align: middle;">发起者部门</label>
                                    <input type="radio" value="1" name="org_rang" id="org_rang_1" style="vertical-align: middle;" /><label for="org_rang_1" style="vertical-align: middle;">处理者部门</label>


                                    <input type="radio" name="org_rang" value="2" id="org_rang_3" style="vertical-align:middle;" /><label for="org_rang_3" style="vertical-align:middle;">自定义</label>：<input type="text" id="org_rang1" class="mymember" style="width:150px;" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>选择类型：</th>
                            <td>
                                <input type="checkbox" value="unit" id="org_type_unit" name="org_type" style="vertical-align: middle;" /><label style="vertical-align: middle;" for="org_type_unit">单位</label>
                                <input type="checkbox" value="dept" id="org_type_dept" name="org_type" style="vertical-align: middle;" /><label style="vertical-align: middle;" for="org_type_dept">部门</label>
                                <input type="checkbox" value="station" id="org_type_station" name="org_type" style="vertical-align: middle;" /><label style="vertical-align: middle;" for="org_type_station">岗位</label>
                                <input type="checkbox" value="wrokgroup" id="org_type_wrokgroup" name="org_type" style="vertical-align: middle;" /><label style="vertical-align: middle;" for="org_type_wrokgroup">角色组</label>
                                <input type="checkbox" value="user" id="org_type_user" name="org_type" style="vertical-align: middle;" /><label style="vertical-align: middle;" for="org_type_user">人员</label>
                            </td>
                        </tr>
                        <tr>
                            <th>多选：</th>
                            <td><input type="checkbox" value="1" id="org_more" style="vertical-align:middle;" /><label for="org_more" style="vertical-align:middle;">是否可以多选</label></td>
                        </tr>
                    </table>
                </div>
                <div id="tabdiv_org_events" style="overflow:auto; padding-top:8px;" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
                    @(await Html.PartialAsync("Events_SubTable.cshtml", "org"))
                </div>
            </div>
            <script type="text/javascript">
                    new RoadUI.Tab({ id: "tabdiv_org", replace: true, contextmenu: false });
            </script>
        </td>
    </tr>

    <tr id="mode_dict" style="display:none;">
        <td colspan="2" style="padding:0; margin:0;">
            <div id="tabdiv_dict" style="width:100%;">
                <div id="tabdiv_dict_base" style="padding-bottom:8px; padding-top:8px;" title="&nbsp;&nbsp;属性&nbsp;&nbsp;">
                    <table cellpadding="0" cellspacing="1" border="0" width="100%" class="formtable">
                        <tr>
                            <th style="width:100px;">默认值：</th>
                            <td>
                                <select class="myselect" id="dict_defaultvalueselect" name="defaultvalueselect" onchange="parent.insertElementText(document.getElementById('dict_defaultvalue'), this.value);" style="width:190px"></select>
                                <input type="text" class="mytext" id="dict_defaultvalue" style="width:380px; margin-right:6px;" />
                            </td>
                        </tr>
                        <tr>
                            <th style="width:100px;">宽度：</th>
                            <td><input type="text" id="dict_width" class="mytext" style="width:150px" /></td>
                        </tr>
                        <tr>
                            <th>选择范围：</th>
                            <td>
                                <div style="padding-top:5px;"><input type="text" id="dict_rang" class="mydict" style="width:200px;" /></div>
                            </td>
                        </tr>
                        <tr>
                            <th>是否多选：</th>
                            <td><input type="checkbox" id="dict_more" value="1" style="vertical-align:middle;" /><label for="dict_more" style="vertical-align:middle;">是否允许多选</label></td>
                        </tr>
                    </table>
                </div>
                <div id="tabdiv_dict_events" style="overflow:auto; padding-top:8px;" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
                    @(await Html.PartialAsync("Events_SubTable.cshtml", "dict"))
                </div>
            </div>
            <script type="text/javascript">
                    new RoadUI.Tab({ id: "tabdiv_dict", replace: true, contextmenu: false });
            </script>
        </td>
    </tr>

    <tr id="mode_files" style="display:none;">
        <td colspan="2">
            <table cellpadding="0" cellspacing="1" border="0" width="100%" class="formtable">
                <tr>
                    <th style="width:100px;">宽度：</th>
                    <td><input type="text" id="files_width" class="mytext" style="width:150px" /></td>
                </tr>
                <tr>
                    <th>文件类型：</th>
                    <td>
                        <div style="margin-top:3px;"><input type="text" id="files_filetype" class="mytext" style="width:97%" /></div>
                        <div style="margin-top:3px;">格式：jpg,png,gif,doc,docx</div>
                    </td>
                </tr>
            </table>
        </td>
    </tr>

</table>
<div class="buttondiv">
    <input type="submit" value=" 确 定 " onclick="confirm1();" class="mybutton" />
    <input type="button" class="mybutton" value=" 取 消 " style="margin-left: 5px;" onclick="closewin();" />
</div>
<script type="text/javascript">
    var win = new RoadUI.Window();
    var eid = '@ViewData["eid"]';
    var ele = win.getOpenerElement(eid);
    var elehidden = win.getOpenerElement(eid + "_hidden");
    var dbconn = '@ViewData["dbconn"]';
    var secondtable = '@ViewData["secondtable"]';
    var editjsonpublic = {};
    var scripts = [];
    var editorWin = null;//编辑器窗口
    var subtableWin = null;//子表设置窗口
    $(function () {
        subtableWin = win.getOpenerWindow();
        if (subtableWin) {
            editorWin = subtableWin.parent;
        }
        $("[name='defaultvalueselect']").html(editorWin.getDefaultValueOptions()).val('');
        $("[name='valuetype']").html(editorWin.getValueTypeOptions()).val('');
        $("#select_Linkage_Field").html('<option value=""></option>' + editorWin.getFields(dbconn, secondtable, ''));

        //加载事件下拉选项
        if ($("[id^='event_name'").size() > 0) {
            $("[id^='event_name'").html(editorWin.getEventsOptions());
        }
        if (elehidden.size() > 0) {
            var jsonstr = elehidden.val();
            if (jsonstr.length > 0) {
                var editjson = JSON.parse(jsonstr);
                var editmode = editjson.editmode;
                editjsonpublic = editjson;
                $("#editmode").val(editmode);
                $("#mode_" + editmode).show();
                scripts = editjson.scripts || [];
                //初始加载事件脚本
                for (var i = 0; i < scripts.length; i++)
                {
                    if (scripts[i].elementName == eid && scripts[i].script && $.trim(scripts[i].script).length > 0) {
                        $("#event_name_" + editmode + "_" + eid).val(scripts[i].name);
                        $("#event_script_" + editmode + "_" + eid).val(RoadUI.Core.unescape(scripts[i].script));
                        break;
                    }
                }
                switch (editmode) {
                    case "text":
                        $("#text_defaultvalue").val(RoadUI.Core.unescape(editjson.text_defaultvalue));
                        $("#text_defaultvalueselect").val(RoadUI.Core.unescape(editjson.text_defaultvalue));
                        $("#text_valuetype").val(editjson.text_valuetype);
                        $("#text_maxlength").val(editjson.text_maxlength);
                        $("#text_width").val(editjson.text_width);
                        break;
                    case "textarea":
                        $("#textarea_defaultvalue").val(RoadUI.Core.unescape(editjson.textarea_defaultvalue));
                        $("#textarea_defaultvalueselect").val(RoadUI.Core.unescape(editjson.textarea_defaultvalue));
                        $("#textarea_valuetype").val(editjson.textarea_valuetype);
                        $("#textarea_maxlength").val(editjson.textarea_maxlength);
                        $("#textarea_width").val(editjson.textarea_width);
                        $("#textarea_height").val(editjson.textarea_height);
                        break;
                    case "select":
                        $("#select_defaultvalue").val(RoadUI.Core.unescape(editjson.select_defaultvalue));
                        $("#select_defaultvalueselect").val(RoadUI.Core.unescape(editjson.select_defaultvalue));
                        $("#select_width").val(editjson.select_width);
                        $("input[name='select_ds'][value='" + editjson.select_ds + "']").prop("checked", true);
                        $("#select_ds_dict").val(editjson.select_ds_dict);
                        $("#select_ds_sql").val(RoadUI.Core.unescape(editjson.select_ds_sql));
                        $("#select_ds_string").val(RoadUI.Core.unescape(editjson.select_ds_string));
                        $("#select_hasempty").prop("checked", "1" == editjson.select_hasempty);
                        $("#select_ds_dict_ischild").prop("checked", "1" == editjson.select_ds_dict_ischild);
                        $("#select_ds_dict_valuefield").val(editjson.select_ds_dict_valuefield || 'id');
                        $("#select_Linkage_Field").val(editjson.select_Linkage_Field);
                        $("input[name='select_Linkage_Source'][value='" + editjson.select_Linkage_Source + "']").prop("checked", true);
                        $("#select_Linkage_Source_sql_conn").val(editjson.select_Linkage_Source_sql_conn);
                        $("#select_Linkage_Source_text").val(RoadUI.Core.unescape(editjson.select_Linkage_Source_text));
                        
                        if ("sql" == editjson.select_Linkage_Source)
                        { 
                            $("#select_Linkage_Source_sql_link").show();
                        }
                        new RoadUI.Dict().setValue($("#select_ds_dict"));
                        new RoadUI.Dict().setValue($("#select_ds_dict"));
                        break;
                    case "checkbox":
                        $("#checkbox_defaultvalue").val(RoadUI.Core.unescape(editjson.checkbox_defaultvalue));
                        $("#checkbox_defaultvalueselect").val(RoadUI.Core.unescape(editjson.checkbox_defaultvalue));
                        $("input[name='checkbox_ds'][value='" + editjson.checkbox_ds + "']").prop("checked", true);
                        $("#checkbox_ds_dict").val(editjson.checkbox_ds_dict);
                        $("#checkbox_ds_sql").val(RoadUI.Core.unescape(editjson.checkbox_ds_sql));
                        $("#checkbox_ds_string").val(RoadUI.Core.unescape(editjson.checkbox_ds_string));
                        new RoadUI.Dict().setValue($("#checkbox_ds_dict"));
                        $("#checkbox_ds_dict_valuefield").val(editjson.checkbox_ds_dict_valuefield || 'id');
                        break;
                    case "radio":
                        $("#radio_defaultvalue").val(RoadUI.Core.unescape(editjson.radio_defaultvalue));
                        $("#radio_defaultvalueselect").val(RoadUI.Core.unescape(editjson.radio_defaultvalue));
                        $("input[name='radio_ds'][value='" + editjson.radio_ds + "']").prop("checked", true);
                        $("#radio_ds_dict").val(editjson.radio_ds_dict);
                        $("#radio_ds_sql").val(editjson.radio_ds_sql);
                        $("#radio_ds_string").val(editjson.radio_ds_string);
                        new RoadUI.Dict().setValue($("#radio_ds_dict"));
                        $("#radio_ds_dict_valuefield").val(editjson.radio_ds_dict_valuefield || 'id');
                        break;
                    case "datetime":
                        $("#datetime_defaultvalue").val(RoadUI.Core.unescape(editjson.datetime_defaultvalue));
                        $("#datetime_defaultvalueselect").val(RoadUI.Core.unescape(editjson.datetime_defaultvalue));
                        $("#datetime_width").val(editjson.datetime_width);
                        $("#datetime_min").val(editjson.datetime_min);
                        $("#datetime_max").val(editjson.datetime_max);
                        $("#datetime_istime").prop("checked", "1" == editjson.datetime_istime);
                        $("#datetime_format").val(editjson.datetime_format);
                        break;
                    case "org":
                        $("#org_defaultvalue").val(RoadUI.Core.unescape(editjson.org_defaultvalue));
                        $("#org_defaultvalueselect").val(RoadUI.Core.unescape(editjson.org_defaultvalue));
                        $("#org_width").val(editjson.org_width);
                        $("input[name='org_rang'][value='" + editjson.org_rang + "']").prop("checked", true);
                        $("#org_rang1").val(editjson.org_rang1);
                        new RoadUI.Member().setValue($("#org_rang1"));
                        var org_type = editjson.org_type;
                        if (org_type) {
                            $("input[name='org_type']").each(function () {
                                if (org_type.indexOf(',' + $(this).val() + ',') >= 0) {
                                    $(this).prop('checked', true);
                                }
                            });
                        }
                        $("#org_more").prop("checked", "1" == editjson.org_more);
                        break;
                    case "dict":
                        $("#dict_defaultvalue").val(RoadUI.Core.unescape(editjson.dict_defaultvalue));
                        $("#dict_defaultvalueselect").val(RoadUI.Core.unescape(editjson.dict_defaultvalue));
                        $("#dict_width").val(editjson.dict_width);
                        $("#dict_rang").val(editjson.dict_rang);
                        new RoadUI.Dict().setValue($("#dict_rang"));
                        $("#dict_more").prop("checked", "1" == editjson.dict_more);
                        break;
                    case "files":
                        $("#files_width").val(editjson.files_width);
                        $("#files_filetype").val(editjson.files_filetype);
                        break;
                }
            }
        }
    });
    function insertElementText(e, value) {
        editorWin.insertElementText(e, value);
    }
    function loadEvent(eventName, eid1, model) {
        var isIn = false;
        if (!eventName || eventName.length == 0) {
            return isIn;
        }
        if (!$.isArray(scripts)) {
            return isIn;
        }
        for (var i = 0; i < scripts.length; i++) {
            if (scripts[i].name == eventName && scripts[i].elementName == eid)
            {
                $("#event_script_" + model + "_" + eid1).val(scripts[i].script && scripts[i].script.length > 0 ?
                    RoadUI.Core.unescape(scripts[i].script) : "");
                isIn = true;
                break;
            }
        }
        if (!isIn)
        {
            $("#event_script_" + model + "_" + eid1).val("");
        }
        return isIn;
    }
    function setEvent(value, eid1, model) {
        var isEmpty = !value || $.trim(value).length == 0;
        var eventName = $("#event_name_" + model + "_" + eid1).val() || "";
        if(!eventName || $.trim(eventName).length==0){
            alert('请选择事件!');
            return;
        }
        var js = value;
        var isIn = false;
        for (var i = 0; i < scripts.length; i++) {
            if (scripts[i].name == eventName && scripts[i].elementName == eid) {
                if(isEmpty){
                    scripts.remove(scripts[i]);
                    return;
                }
                scripts[i].script = RoadUI.Core.escape(js);
                if (!scripts[i].id) {
                    scripts[i].id = RoadUI.Core.newid(false).toUpperCase();
                }
                isIn = true;
                break;
            }
        }

        if (!isIn && !isEmpty) {
            scripts.push({
                "id": RoadUI.Core.newid(false).toUpperCase(),
                "name": eventName,
                "elementName": eid,
                "script": RoadUI.Core.escape(js)
            });
        }
    }

    function editmode_change(mode) {
        $("#maintable tr[id^='mode_']").hide();
        $("#mode_" + mode).show();
    }

    function confirm1() {
        var mode = $("#editmode").val();
        var editjson = {};
        var edittxt = "";
        editjson.editmode = mode;
        editjson.secondtable = secondtable;
        editjson.scripts = scripts;
        switch (mode) {
            case "text":
                edittxt = "文本框";
                editjson.text_defaultvalue = RoadUI.Core.escape($("#text_defaultvalue").val() || '');
                editjson.text_valuetype = $("#text_valuetype").val() || '';
                editjson.text_maxlength = $("#text_maxlength").val() || '';
                editjson.text_width = $("#text_width").val() || '';
                break;
            case "textarea":
                edittxt = "文本域";
                editjson.textarea_defaultvalue = RoadUI.Core.escape($("#textarea_defaultvalue").val() || '');
                editjson.textarea_valuetype = $("#textarea_valuetype").val() || '';
                editjson.textarea_maxlength = $("#textarea_maxlength").val() || '';
                editjson.textarea_width = $("#textarea_width").val() || '';
                editjson.textarea_height = $("#textarea_height").val() || '';
                break;
            case "select":
                edittxt = "下拉选择";
                editjson.select_width = $("#select_width").val() || '';
                editjson.select_ds = $(":checked[name='select_ds']").val() || '';
                editjson.select_ds_dict = $("#select_ds_dict").val() || '';
                editjson.select_ds_sql = RoadUI.Core.escape($("#select_ds_sql").val() || '');
                editjson.select_ds_string = RoadUI.Core.escape($("#select_ds_string").val() || '');
                editjson.select_hasempty = $("#select_hasempty").prop("checked") ? "1" : "0";
                editjson.select_defaultvalue = RoadUI.Core.escape($("#select_defaultvalue").val() || "");
                editjson.select_ds_dict_ischild = $("#select_ds_dict_ischild").prop("checked") ? "1" : "0";
                editjson.select_ds_dict_valuefield = $("#select_ds_dict_valuefield").val() || 'id';
                editjson.select_Linkage_Field = $("#select_Linkage_Field").val() || '';
                editjson.select_Linkage_Source = $(":checked[name='select_Linkage_Source']").val() || '';
                editjson.select_Linkage_Source_sql_conn = $("#select_Linkage_Source_sql_conn").val() || '';
                editjson.select_Linkage_Source_text = RoadUI.Core.escape($("#select_Linkage_Source_text").val() || '');
                break;
            case "checkbox":
                edittxt = "复选框";
                editjson.checkbox_defaultvalue = RoadUI.Core.escape($("#checkbox_defaultvalue").val() || "");
                editjson.checkbox_ds = $(":checked[name='checkbox_ds']").val();
                editjson.checkbox_ds_dict = $("#checkbox_ds_dict").val();
                editjson.checkbox_ds_dict_valuefield = $("#checkbox_ds_dict_valuefield").val() || "id";
                editjson.checkbox_ds_sql = RoadUI.Core.escape($("#checkbox_ds_sql").val() || "");
                editjson.checkbox_ds_string = RoadUI.Core.escape($("#checkbox_ds_string").val() || "");
                break;
            case "radio":
                edittxt = "单选框";
                editjson.radio_defaultvalue = RoadUI.Core.escape($("#radio_defaultvalue").val() || "");
                editjson.radio_ds = $(":checked[name='radio_ds']").val() || "";
                editjson.radio_ds_dict = $("#radio_ds_dict").val() || "";
                editjson.radio_ds_dict_valuefield = $("#radio_ds_dict_valuefield").val() || "id";
                editjson.radio_ds_sql = $("#radio_ds_sql").val() || "";
                editjson.radio_ds_string = $("#radio_ds_string").val() || "";
                break;
            case "datetime":
                edittxt = "日期时间";
                editjson.datetime_defaultvalue = RoadUI.Core.escape($("#datetime_defaultvalue").val() || "");
                editjson.datetime_width = $("#datetime_width").val() || "";
                editjson.datetime_min = $("#datetime_min").val() || "";
                editjson.datetime_max = $("#datetime_max").val() || "";
                editjson.datetime_istime = $("#datetime_istime").prop("checked") ? "1" : "0";
                editjson.datetime_format = $("#datetime_format").val() || "";
                break;
            case "org":
                edittxt = "组织架构";
                editjson.org_defaultvalue = RoadUI.Core.escape($("#org_defaultvalue").val() || "");
                editjson.org_width = $("#org_width").val() || "";
                editjson.org_rang = $(":checked[name='org_rang']").val() || "";
                editjson.org_rang1 = $("#org_rang1").val() || "";
                var org_type = ",";
                $(":checked[name='org_type']").each(function () {
                    org_type += $(this).val() + ",";
                });
                editjson.org_type = org_type;
                editjson.org_more = $("#org_more").prop("checked") ? "1" : "0";
                break;
            case "dict":
                edittxt = "数据字典";
                editjson.dict_defaultvalue = RoadUI.Core.escape($("#dict_defaultvalue").val() || "");
                editjson.dict_width = $("#dict_width").val() || "";
                editjson.dict_rang = $("#dict_rang").val() || "";
                editjson.dict_more = $("#dict_more").prop("checked") ? "1" : "0";
                break;
            case "files":
                edittxt = "附件";
                editjson.files_width = $("#files_width").val();
                editjson.files_filetype = $("#files_filetype").val();
                break;
        }

        editjson.title = edittxt;
        if (ele.size() > 0) {
            ele.val(edittxt);
        }
        if (elehidden.size() > 0) {
            elehidden.val(JSON.stringify(editjson));
        }
        win.close();
        return false;
    }

    function closewin() {
        win.close();
        return false;
    }

    function testSql(sql, connId)
    {
        editorWin.testSql(sql, connId);
    }
</script>